package com.atguigu.spzx.feign.product;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import vo.common.dto.product.SkuSaleDto;
import vo.common.entity.product.ProductSku;

import java.util.List;


/**
 * ***** 远程调用 OpenFeign
 *
 *       1、使用步骤
 *          - 调用方启动类上添加注解@EnableFeignClients(basePackages = {"com.atguigu.spzx"})
 *          - 定义远程调用接口
 *              接口所在的服务：@FeignClient(value = "service-product")
 *              接口所在的路径和参数：@GetMapping("/api/product/getBySkuId/{skuId}")
 *          - 调用方引入service-product-client包的依赖
 */
@FeignClient(value = "service-product")
public interface ProductFeignClient {

    /**
     * @Description: 远程调用：根据商品skuId获取商品sku信息
     * @param skuId
     */
    @GetMapping("/api/product/getBySkuId/{skuId}")
    ProductSku getBySkuId(@PathVariable Long skuId);

    /**
     * 更新商品sku销量
     * @param skuSaleDtoList
     * @return
     */
    @PostMapping("/api/product/updateSkuSaleNum")
    Boolean updateSkuSaleNum(@RequestBody List<SkuSaleDto> skuSaleDtoList);

}
